/**
 * 
 */
package com.oolong.account.util;

import java.util.List;

import com.oolong.account.web.LoadGlobalParameter;

/**
 * @author oolong
 * 
 */
public class ParamterCheck {
	public static boolean checkPassword(String psw) {
		return (psw != null) && psw.matches("^[A-Za-z0-9]+$")
				&& (psw.length() <= 15) && (psw.length() > 0);
	}

	public static boolean checkName(String name) {
		return (name != null)
				&& name.matches("^[\\u4E00-\\u9FA5\\uF900-\\uFA2D\\w]+$")
				&& (name.length() <= 15) && (name.length() > 0);
	}

	public static boolean checkEmail(String email) {
		return (email != null)
				&& email.matches("^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$")
				&& (email.length() <= 128) && (email.length() > 0);
	}

	public static boolean oneTypeCheck(int type) {
		List<Integer> ids = LoadGlobalParameter.oneids;
		return ids.contains(type);
	}

	public static boolean towTypeCheck(int type) {
		List<Integer> ids = LoadGlobalParameter.twoids;
		return ids.contains(type);
	}

	public static boolean checkMemo(String memo) {
		return (memo == null)
				|| ((memo.length() <= 128) && (memo.length() >= 0));
	}
}
